package src.stu23002152.chapter07;

import java.util.ArrayList;
import java.util.Collections;

public class Demo22 {
    public static void main(String[] args) {
        ArrayList<String> list23002152 = new ArrayList<>();
        Collections.addAll(list23002152, "C","Z","B","K");    // 添加元素
        System.out.println("排序前: " + list23002152);
        Collections.reverse(list23002152);                       // 反转集合
        System.out.println("反转后： " + list23002152);
        Collections.sort(list23002152);                           // 按自然顺序排列
        System.out.println("按自然顺序排序后: " + list23002152);
        Collections.shuffle(list23002152);                       // 随机打乱集合元素
        System.out.println("按随机顺序排序后:  " + list23002152);
        Collections.swap(list23002152, 0, list23002152.size()-1);     // 将集合首尾元素交换
        System.out.println("集合首尾元素交换后: " + list23002152);
        //11.16
    }
}
